package com.w.tank;

public class TankWarColl implements Collider{
    @Override
    public boolean collide(GameObject g1, GameObject g2) {
       if(g1 instanceof Tank && g2 instanceof Wall || g1 instanceof Wall && g2 instanceof Tank){
           Wall w = null;
           Tank tk = null;
           try {
               tk = (Tank)g1;
               w = (Wall)g2;
           }catch (Exception e){
               tk = (Tank)g2;
               w = (Wall)g1;
           }
           if(w.rect.intersects(tk.rect)){
               tk.setX(tk.old_x);
               tk.setY(tk.old_y);
           }



       }
       return false;

    }
}
